/*
	Title: 02_Table11.do
	Paper: Brauning, Ivashina, Ozdagli (2025)
	Description: Table 11 - The role of direct restrictions on investment, quasi-cov-lite loans and amended contracts
*/

/*------------------------------------------------------------------------------
								  Table 11
------------------------------------------------------------------------------*/
// Import Table 11 data
use "$data_path/Table11.dta", clear 


// Table Setup -----------------------------------------------------------------
putdocx clear 
putdocx begin, landscape
putdocx paragraph
putdocx table table11 = (18, 11), border(insideV, nil) border(insideH, nil) border(left, nil) border(right, nil)

* Top margin
putdocx table table11(1,2), colspan(10)
putdocx table table11(1,2) = ("Investment (% Capital)")
putdocx table table11(1,2), border(bottom)

putdocx table table11(2,2), colspan(2)
putdocx table table11(2,2) = ("Incurrence w/o payment restrictions")
putdocx table table11(2,3), colspan(2)
putdocx table table11(2,3) = ("Incurrence w/ payment restrictions")
putdocx table table11(2,4), colspan(2)
putdocx table table11(2,4) = ("Excl. incurrence w/ investment restrictions")
putdocx table table11(2,5), colspan(2)
putdocx table table11(2,5) = ("Excl. maintenance on revolving line")
putdocx table table11(2,6), colspan(2)
putdocx table table11(2,6) = ("Excl. contracts w/ amendments")


putdocx table table11(3,2) = ("(1)")
putdocx table table11(3,3) = ("(2)")
putdocx table table11(3,4) = ("(3)")
putdocx table table11(3,5) = ("(4)")
putdocx table table11(3,6) = ("(5)")
putdocx table table11(3,7) = ("(6)")
putdocx table table11(3,8) = ("(7)")
putdocx table table11(3,9) = ("(8)")
putdocx table table11(3,10) = ("(9)")
putdocx table table11(3,11) = ("(10)")
putdocx table table11(3,.), border(bottom) 

* Left margin
putdocx table table11(5,1) = ("Incurrence bind")
putdocx table table11(7,1) = ("Maintenance bind")
putdocx table table11(10,1) = ("Observations")
putdocx table table11(11,1) = ("R-Squared")
putdocx table table11(12,1) = ("Firm FE")
putdocx table table11(13,1) = ("Quarter FE")
putdocx table table11(14,1) = ("Controls")
putdocx table table11(15,1) = ("Controls*Cov-type")
putdocx table table11(16,1) = ("Quarter*Cov-type FE")
putdocx table table11(17,1) = ("H0: Incurrence=Maintenance")
putdocx table table11(18,1) = ("p-value")


// Define Regression Specifications --------------------------------------------
local LHS "capex_capital_ratio_tr" 

local controls0   "L_macroq_tr L_logatq_tr cashflowq_tr" 
local dd_controls " L_DD_Total_final_tr L_DD_Total_final_sq_tr"
local controls    "`controls0' `dd_controls'"

local cond0 "L.dealscan <= 1"
local cond1 "_b1_diff_std <= 2 & _b2_diff_std <= 2"
local cond2 "(!mi(lev_limit) | !mi(intcov_limit) | !mi(Ilev_limit) | !mi(Iintcov_limit))"
local conditions "`cond0' & `cond1' & `cond2'"


// Column (1) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation `controls' L_incurrence L_maintenance if `conditions' & flag_payout_cov == 0, ///
			  absorb(xdim qdate) cluster(xdim qdate)
			  
// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,2) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,2) = ("(`incurrence_se')")
putdocx table table11(7,2) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,2) = ("(`maintenance_se')")
putdocx table table11(10,2) = (`N')
putdocx table table11(11,2) = (`r2')
putdocx table table11(12,2) = ("Yes")
putdocx table table11(13,2) = ("Yes")
putdocx table table11(14,2) = ("Yes")
putdocx table table11(15,2) = ("No")
putdocx table table11(16,2) = ("No")
putdocx table table11(17,2) = (`estimate')
putdocx table table11(18,2) = (`p')
	

// Column (2) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation (L_incurrence L_maintenance)##c.(`controls') if `conditions' & flag_payout_cov == 0, ///
			  absorb(xdim L_incurrence#qdate L_maintenance#qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,3) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,3) = ("(`incurrence_se')")
putdocx table table11(7,3) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,3) = ("(`maintenance_se')")
putdocx table table11(10,3) = (`N')
putdocx table table11(11,3) = (`r2')
putdocx table table11(12,3) = ("Yes")
putdocx table table11(13,3) = ("Yes")
putdocx table table11(14,3) = ("Yes")
putdocx table table11(15,3) = ("Yes")
putdocx table table11(16,3) = ("Yes")
putdocx table table11(17,3) = (`estimate')
putdocx table table11(18,3) = (`p')


// Column (3) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation `controls' L_incurrence L_maintenance if `conditions' & flag_payout_cov == 1, ///
			  absorb(xdim qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,4) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,4) = ("(`incurrence_se')")
putdocx table table11(7,4) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,4) = ("(`maintenance_se')")
putdocx table table11(10,4) = (`N')
putdocx table table11(11,4) = (`r2')
putdocx table table11(12,4) = ("Yes")
putdocx table table11(13,4) = ("Yes")
putdocx table table11(14,4) = ("Yes")
putdocx table table11(15,4) = ("No")
putdocx table table11(16,4) = ("No")
putdocx table table11(17,4) = (`estimate')
putdocx table table11(18,4) = (`p')


// Column (4) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation (L_incurrence L_maintenance)##c.(`controls') if `conditions' & flag_payout_cov == 1, ///
			  absorb(xdim L_incurrence#qdate L_maintenance#qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,5) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,5) = ("(`incurrence_se')")
putdocx table table11(7,5) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,5) = ("(`maintenance_se')")
putdocx table table11(10,5) = (`N')
putdocx table table11(11,5) = (`r2')
putdocx table table11(12,5) = ("Yes")
putdocx table table11(13,5) = ("Yes")
putdocx table table11(14,5) = ("Yes")
putdocx table table11(15,5) = ("Yes")
putdocx table table11(16,5) = ("Yes")
putdocx table table11(17,5) = (`estimate')
putdocx table table11(18,5) = (`p')


// Column (5) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation `controls' L_incurrence L_maintenance if `conditions' & has_investment_restriction == 0, ///
			  absorb(xdim qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,6) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,6) = ("(`incurrence_se')")
putdocx table table11(7,6) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,6) = ("(`maintenance_se')")
putdocx table table11(10,6) = (`N')
putdocx table table11(11,6) = (`r2')
putdocx table table11(12,6) = ("Yes")
putdocx table table11(13,6) = ("Yes")
putdocx table table11(14,6) = ("Yes")
putdocx table table11(15,6) = ("No")
putdocx table table11(16,6) = ("No")
putdocx table table11(17,6) = (`estimate')
putdocx table table11(18,6) = (`p')


// Column (6) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation (L_incurrence L_maintenance)##c.(`controls') if `conditions' & has_investment_restriction == 0, ///
			  absorb(xdim L_incurrence#qdate L_maintenance#qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,7) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,7) = ("(`incurrence_se')")
putdocx table table11(7,7) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,7) = ("(`maintenance_se')")
putdocx table table11(10,7) = (`N')
putdocx table table11(11,7) = (`r2')
putdocx table table11(12,7) = ("Yes")
putdocx table table11(13,7) = ("Yes")
putdocx table table11(14,7) = ("Yes")
putdocx table table11(15,7) = ("Yes")
putdocx table table11(16,7) = ("Yes")
putdocx table table11(17,7) = (`estimate')
putdocx table table11(18,7) = (`p')


// Column (7) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation `controls' L_incurrence L_maintenance if `conditions' & revolving_flag == 0, ///
			  absorb(xdim qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,8) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,8) = ("(`incurrence_se')")
putdocx table table11(7,8) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,8) = ("(`maintenance_se')")
putdocx table table11(10,8) = (`N')
putdocx table table11(11,8) = (`r2')
putdocx table table11(12,8) = ("Yes")
putdocx table table11(13,8) = ("Yes")
putdocx table table11(14,8) = ("Yes")
putdocx table table11(15,8) = ("No")
putdocx table table11(16,8) = ("No")
putdocx table table11(17,8) = (`estimate')
putdocx table table11(18,8) = (`p')


// Column (8) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation (L_incurrence L_maintenance)##c.(`controls') if `conditions' & revolving_flag == 0, ///
			  absorb(xdim L_incurrence#qdate L_maintenance#qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,9) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,9) = ("(`incurrence_se')")
putdocx table table11(7,9) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,9) = ("(`maintenance_se')")
putdocx table table11(10,9) = (`N')
putdocx table table11(11,9) = (`r2')
putdocx table table11(12,9) = ("Yes")
putdocx table table11(13,9) = ("Yes")
putdocx table table11(14,9) = ("Yes")
putdocx table table11(15,9) = ("Yes")
putdocx table table11(16,9) = ("Yes")
putdocx table table11(17,9) = (`estimate')
putdocx table table11(18,9) = (`p')


// Column (9) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation `controls' L_incurrence L_maintenance if `conditions' & amend_ind_fill == 0, ///
			  absorb(xdim qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,10) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,10) = ("(`incurrence_se')")
putdocx table table11(7,10) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,10) = ("(`maintenance_se')")
putdocx table table11(10,10) = (`N')
putdocx table table11(11,10) = (`r2')
putdocx table table11(12,10) = ("Yes")
putdocx table table11(13,10) = ("Yes")
putdocx table table11(14,10) = ("Yes")
putdocx table table11(15,10) = ("No")
putdocx table table11(16,10) = ("No")
putdocx table table11(17,10) = (`estimate')
putdocx table table11(18,10) = (`p')


// Column (10) ------------------------------------------------------------------
// Regression: 
reghdfe `LHS' L_Iin_covenant_violation L_Min_covenant_violation (L_incurrence L_maintenance)##c.(`controls') if `conditions' & amend_ind_fill == 0, ///
			  absorb(xdim L_incurrence#qdate L_maintenance#qdate) cluster(xdim qdate)

// Store results 
matrix reg_results = r(table)
local incurrence_b : display %04.2f reg_results["b", "L_Iin_covenant_violation"]   
local incurrence_se : display %04.2f reg_results["se", "L_Iin_covenant_violation"]
local incurrence_p = reg_results["pvalue", "L_Iin_covenant_violation"]

if (`incurrence_p' > 0.1) {
	local incurrence_sigstars = ""
} 
if (`incurrence_p' < 0.1) {
	local incurrence_sigstars = "*"
}
if (`incurrence_p' < 0.05) {
	local incurrence_sigstars = "**"
}
if (`incurrence_p' < 0.01) {
	local incurrence_sigstars = "***"
}

local maintenance_b : display %04.2f reg_results["b", "L_Min_covenant_violation"]
local maintenance_se : display %04.2f reg_results["se", "L_Min_covenant_violation"]
local maintenance_p = reg_results["pvalue", "L_Min_covenant_violation"]

if (`maintenance_p' > 0.1) {
	local maintenance_sigstars = ""
} 
if (`maintenance_p' < 0.1) {
	local maintenance_sigstars = "*"
}
if (`maintenance_p' < 0.05) {
	local maintenance_sigstars = "**"
}
if (`maintenance_p' < 0.01) {
	local maintenance_sigstars = "***"
}
local N = e(N)
local r2 : display %9.2f  e(r2)

* H0: Incurrence = Maintenance (results stored in r(estimate) and r(p))
lincom L_Min_covenant_violation - L_Iin_covenant_violation
local estimate = r(estimate)
local p: display %9.4f  r(p)

// Put results into table in Word Document 
putdocx table table11(5,11) = ("`incurrence_b'`incurrence_sigstars'")
putdocx table table11(6,11) = ("(`incurrence_se')")
putdocx table table11(7,11) = ("`maintenance_b'`maintenance_sigstars'")
putdocx table table11(8,11) = ("(`maintenance_se')")
putdocx table table11(10,11) = (`N')
putdocx table table11(11,11) = (`r2')
putdocx table table11(12,11) = ("Yes")
putdocx table table11(13,11) = ("Yes")
putdocx table table11(14,11) = ("Yes")
putdocx table table11(15,11) = ("Yes")
putdocx table table11(16,11) = ("Yes")
putdocx table table11(17,11) = (`estimate')
putdocx table table11(18,11) = (`p')



// Table Setup (end) -----------------------------------------------------------
putdocx table table11(.,2/11), halign(center)
putdocx table table11(.,1), width(3 in)

* Number formatting
putdocx table table11(6,2/11), nformat(%04.2f)
putdocx table table11(8,2/11), nformat(%04.2f)
putdocx table table11(10,2/11), nformat(%9.0fc)
putdocx table table11(11,2/11), nformat(%9.2g)
putdocx table table11(17,2/11), nformat(%05.3f)
putdocx table table11(18,2/11), nformat(%9.4g) 

* Table-wide formatting
putdocx table table11(.,.), font("Times New Roman", 9)


putdocx save "$tables_path/Table11.docx", replace